package com.hsc.www.validator.test1;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.HashMap;

@RestController
@Validated
public class PeController {

    @GetMapping("/getUser")
    public Object getUser(
            @NotEmpty(message = "不能为空")
                    String name,
            @NotNull(message = "不能为空")
            @Min(value = 18, message = "不能小于18")
                    Integer age) {

        return new HashMap<String, Object>() {{
            put("name", name);
            put("age", age);
        }};
    }
}